Optimal. Leaf size=61 \[ -\frac {2 \sqrt {a-b} \sqrt {a+b} \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a^2}-\frac {b \tanh ^{-1}(\sin (x))}{a^2}+\frac {\tan (x)}{a} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.15, antiderivative size = 61, normalized size of antiderivative = 1.00, number of steps
used = 6, number of rules used = 6, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.462, Rules used = {2802, 3135,
3080, 3855, 2738, 211} \begin {gather*} -\frac {2 \sqrt {a-b} \sqrt {a+b} \text {ArcTan}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a^2}-\frac {b \tanh ^{-1}(\sin (x))}{a^2}+\frac {\tan (x)}{a} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 211
Rule 2738
Rule 2802
Rule 3080
Rule 3135
Rule 3855
Rubi steps
\begin {align*} \int \frac {\tan ^2(x)}{a+b \cos (x)} \, dx &=\int \frac {\left (1-\cos ^2(x)\right ) \sec ^2(x)}{a+b \cos (x)} \, dx\\ &=\frac {\tan (x)}{a}+\frac {\int \frac {(-b-a \cos (x)) \sec (x)}{a+b \cos (x)} \, dx}{a}\\ &=\frac {\tan (x)}{a}-\frac {b \int \sec (x) \, dx}{a^2}+\frac {\left (-a^2+b^2\right ) \int \frac {1}{a+b \cos (x)} \, dx}{a^2}\\ &=-\frac {b \tanh ^{-1}(\sin (x))}{a^2}+\frac {\tan (x)}{a}+\frac {\left (2 \left (-a^2+b^2\right )\right ) \text {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^2}\\ &=-\frac {2 \sqrt {a-b} \sqrt {a+b} \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {x}{2}\right )}{\sqrt {a+b}}\right )}{a^2}-\frac {b \tanh ^{-1}(\sin (x))}{a^2}+\frac {\tan (x)}{a}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.20, size = 85, normalized size = 1.39 \begin {gather*} \frac {-2 \sqrt {-a^2+b^2} \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {x}{2}\right )}{\sqrt {-a^2+b^2}}\right )+b \left (\log \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )-\log \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right )\right )+a \tan (x)}{a^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.17, size = 100, normalized size = 1.64
method | result | size |
default | \(-\frac {1}{a \left (\tan \left (\frac {x}{2}\right )-1\right )}+\frac {b \ln \left (\tan \left (\frac {x}{2}\right )-1\right )}{a^{2}}+\frac {2 \left (-a^{2}+b^{2}\right ) \arctan \left (\frac {\left (a -b \right ) \tan \left (\frac {x}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{2} \sqrt {\left (a -b \right ) \left (a +b \right )}}-\frac {1}{a \left (\tan \left (\frac {x}{2}\right )+1\right )}-\frac {b \ln \left (\tan \left (\frac {x}{2}\right )+1\right )}{a^{2}}\) | \(100\) |
risch | \(\frac {2 i}{a \left ({\mathrm e}^{2 i x}+1\right )}+\frac {b \ln \left ({\mathrm e}^{i x}-i\right )}{a^{2}}-\frac {\sqrt {-a^{2}+b^{2}}\, \ln \left ({\mathrm e}^{i x}-\frac {i \sqrt {-a^{2}+b^{2}}-a}{b}\right )}{a^{2}}+\frac {\sqrt {-a^{2}+b^{2}}\, \ln \left ({\mathrm e}^{i x}+\frac {i \sqrt {-a^{2}+b^{2}}+a}{b}\right )}{a^{2}}-\frac {b \ln \left ({\mathrm e}^{i x}+i\right )}{a^{2}}\) | \(134\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.44, size = 203, normalized size = 3.33 \begin {gather*} \left [-\frac {b \cos \left (x\right ) \log \left (\sin \left (x\right ) + 1\right ) - b \cos \left (x\right ) \log \left (-\sin \left (x\right ) + 1\right ) - \sqrt {-a^{2} + b^{2}} \cos \left (x\right ) \log \left (\frac {2 \, a b \cos \left (x\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + 2 \, \sqrt {-a^{2} + b^{2}} {\left (a \cos \left (x\right ) + b\right )} \sin \left (x\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}}\right ) - 2 \, a \sin \left (x\right )}{2 \, a^{2} \cos \left (x\right )}, -\frac {b \cos \left (x\right ) \log \left (\sin \left (x\right ) + 1\right ) - b \cos \left (x\right ) \log \left (-\sin \left (x\right ) + 1\right ) + 2 \, \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \cos \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \sin \left (x\right )}\right ) \cos \left (x\right ) - 2 \, a \sin \left (x\right )}{2 \, a^{2} \cos \left (x\right )}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\tan ^{2}{\left (x \right )}}{a + b \cos {\left (x \right )}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 111 vs.
\(2 (51) = 102\).
time = 0.46, size = 111, normalized size = 1.82 \begin {gather*} -\frac {b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) + 1 \right |}\right )}{a^{2}} + \frac {b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) - 1 \right |}\right )}{a^{2}} + \frac {2 \, {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, x\right ) - b \tan \left (\frac {1}{2} \, x\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )} \sqrt {a^{2} - b^{2}}}{a^{2}} - \frac {2 \, \tan \left (\frac {1}{2} \, x\right )}{{\left (\tan \left (\frac {1}{2} \, x\right )^{2} - 1\right )} a} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.55, size = 77, normalized size = 1.26 \begin {gather*} \frac {2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {x}{2}\right )\,\sqrt {b^2-a^2}}{a\,\cos \left (\frac {x}{2}\right )+b\,\cos \left (\frac {x}{2}\right )}\right )\,\sqrt {b^2-a^2}}{a^2}-\frac {2\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {x}{2}\right )}{\cos \left (\frac {x}{2}\right )}\right )}{a^2}+\frac {\sin \left (x\right )}{a\,\cos \left (x\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________